<template>
  <div>
    <div class="content-item">
      <p>寝室成员
        <span v-if="roomInfo">【{{roomInfo}}】</span>
      </p>
      <el-table :data="dormMerber"
                class="table-header-gray">
        <el-table-column label="序号"
                         type="index"></el-table-column>
        <el-table-column label="姓名"
                         prop="name"></el-table-column>
        <el-table-column label="性别"
                         :formatter="formatGender"
                         prop="gender"></el-table-column>
        <el-table-column label="学院"
                         prop="collegeName"></el-table-column>
        <el-table-column label="年级"
                         prop="gradeName"></el-table-column>
        <el-table-column label="专业"
                         prop="majorName"></el-table-column>
        <el-table-column label="班级"
                         prop="className"></el-table-column>
      </el-table>
      <p>寝室荣誉</p>
      <el-table :data="honor"
                class="table-header-gray">
        <el-table-column label="序号"
                         type="index"></el-table-column>
        <el-table-column label="时间"
                         :formatter="formatTime"
                         prop="effectAt"></el-table-column>
        <el-table-column label="荣誉"
                    :formatter="formatHonorStr"
                         prop="honorStr"></el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { getBedroomHonorUsingGET, listStudentInfoByRoomIdUsingGET } from '@api/auto'
import { formatTool } from '@/tools/mixin'
export default {
  name: '',
  props: {
  },
  mixins: [formatTool],
  components: {},
  data () {
    return {
      roomId: '',
      dormMerber: [],
      honor: [],
      roomInfo: '',
      id: ''
    }
  },
  created () {
    this.roomId = this.$route.query.roomId
    this.id = this.$route.query.id
    this.listStudentInfoByRoomIdUsingGET(this.roomId)
    this.getBedroomHonorUsingGET(Number(this.id))
  },
  mounted () { },
  methods: {
    // 通过寝室id和日期查询寝室成员
    listStudentInfoByRoomIdUsingGET (id) {
      let date = new Date(Number(this.$route.query.date)).toString()
      listStudentInfoByRoomIdUsingGET(id, -1, date)
        .then(res => {
          this.dormMerber = res.data
          if (res.data && res.data.length) {
            this.roomInfo = res.data[0].checkInInfo
          }
        })
    },
    getBedroomHonorUsingGET (id) {
      getBedroomHonorUsingGET(id)
        .then(res => {
          this.honor = res.data
        })
    }
  }
}
</script>
<style lang='less' scoped>
</style>
